<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="ch">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/userInfo/relgoods.css}"/>
    <script type="text/javascript" th:src="@{/static/layui/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/vue.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/userInfo/ckplayer.js}"></script>
    <title>易物校园二手交易商城 | 填写收货地址</title>
    <script th:inline="javascript">
        var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];
    </script>
</head>
<body style="background-color:white">
<form class="layui-form" id="goodsform" style="margin-top: 10px">
    <div class="layui-form-item" style="display: none">
        <label class="layui-form-label"><span style="color: red">*</span>商品di</label>
        <div class="layui-input-block">
            <input type="text" name="commid" lay-verify="required" autocomplete="off" placeholder="商品di"
                   class="layui-input" th:value="${shopid}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red">*</span>收件人</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入收件人名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red">*</span>手机号</label>
        <div class="layui-input-block">
            <input type="number" name="mobilephone" lay-verify="required" autocomplete="off" placeholder="请输入收件人手机号"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span style="color: red">*</span>收件地址</label>
        <div class="layui-input-block">
            <input type="text" name="useraddress" lay-verify="required" autocomplete="off" placeholder="请输入收件地址"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" id="demo1" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>
</body>
<script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
<script>
    layui.use(['form', 'upload', 'element'], function () {
        var upload = layui.upload;
        var form=layui.form;
        form.on('submit(demo1)', function (data) {
            var object = new Object();
            object["commid"] = data.field.commid;
            object["username"] = data.field.username;
            object["mobilephone"] = data.field.mobilephone;
            object["useraddress"] = data.field.useraddress;
            var jsonData = JSON.stringify(object);
            $.ajax({
                url: basePath + "/shop/topay",
                data: jsonData,
                contentType: "application/json;charset=UTF-8",
                type: "put",
                dataType: "json",
                beforeSend: function () {
                    layer.load(1, {
                        content: '请稍等...',
                        success: function (layero) {
                            layero.find('.layui-layer-content').css({
                                'padding-top': '39px',
                                'width': '60px'
                            });
                        }
                    });
                },
                complete: function () {
                    layer.closeAll('loading');
                },
                success: function (data) {
                    layer.msg("正在跳转到支付页面", {
                        time: 1000,
                        icon: 1,
                        offset: '100px'
                    }, function () {
                        var index=parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                        parent.layer.close(index);//关闭窗口
                        window.open(basePath+"/shop/preorder/"+data.data)
                    });
                },error:function () {
                    layer.msg('系统错误', {
                        time: 1000,
                        icon: 2,
                        offset: '150px'
                    });
                }
            });
            return false;
        });
    });
</script>
</html>
